package gwtgaetools.client.ui;

import gwtgaetools.client.comm.GenericClientRPC;
import gwtgaetools.client.comm.GenericMessageInterpreter;
import gwtgaetools.client.comm.GenericRPCServiceAsync;
import gwtgaetools.shared.model.GenericMessage;

import com.google.gwt.user.client.ui.RootLayoutPanel;
import com.google.gwt.user.client.ui.Widget;

/**
 * Main display class. Listens to state changes.
 * @author opowell
 *
 */
public abstract class GenericAppDisplay<
Type, 
MainObject, 
Message extends GenericMessage<Type>, 
RPCService extends GenericRPCServiceAsync<Type, Message>, 
MessageInterpreter extends GenericMessageInterpreter<Type, Message, ?>,
ClientRPC extends GenericClientRPC<Type, MainObject, RPCService, Message, MessageInterpreter>> {

	private RootLayoutPanel root;
	
	public GenericAppDisplay(MainObject m, ClientRPC c) {

		root = RootLayoutPanel.get();
		initUI(m, c);
		
	}
	
	protected abstract void initUI(MainObject m, ClientRPC c);

	/**
	 * load new screen widget 
	 * @param w screen to be loaded
	 */
	protected void setContents(Widget w) {
		root.clear();
		root.add(w);
	}

}
